﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace Tester.DL645.Responses
{
    /// <summary>
    /// 电压响应
    /// </summary>
    public class PhaseVoltageResponse:AbstractReponse
    {
        /// <summary>
        /// 
        /// </summary>
        public Core.Phase Phase { get; set; }

        public decimal Value { get; set; }

       /// <summary>
       /// 
       /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="buffer"></param>
        public PhaseVoltageResponse(byte[] buffer, Core.Phase phase) : base(buffer)
        {
            this.Phase = phase;
        

             this.Value= int.Parse(string.Join("", buffer.Skip(14)
                 .Take(2).Reverse()
                .Select(item => (item - 0x33).ToString("X2")))) *0.1m;

            this.Description = string.Format("{0}：{1}", this.Phase.ToString(), this.Value.ToString());
        }
    }
}
